package com.zhuhan.service.impl;

import com.zhuhan.dao.AccountDao;
import com.zhuhan.domain.Account;
import com.zhuhan.service.AccountService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service/*spring对Service的注解，在xml文件中就不用写bean标签来配置*/
public class AccountServiceImpl implements AccountService {

    @Autowired
    private AccountDao accountDao;

    @Override
    public List<Account> findAll() {
        System.out.println("Service层中的findAll方法");
        List<Account> list = accountDao.findAll();
        return list;
    }

    @Override
    public void addAccount(Account account) {
        System.out.println("Service层中的addAccount方法");
        int row = accountDao.addAccount(account);
//        int a = 1 / 0;
        if (row > 0) {
            System.out.println("添加成功！");
        } else {
            System.out.println("添加失败！");
        }
    }
}
